package com.maybach.web.framework.interceptor;

import com.maybach.web.framework.assets.AssetsConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by houenxun on 16/1/13.
 * 设置
 */
public class AssetsConfigInterceptor  extends HandlerInterceptorAdapter {
    protected Logger log = LoggerFactory.getLogger(this.getClass());
    @Autowired
    protected AssetsConfig assetsConfig;

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if(null != modelAndView){
            modelAndView.addAllObjects(assetsConfig.getConfigMap());
        }
        super.postHandle(request, response, handler, modelAndView);
    }
}
